/*
 * GameAspect.aj
 * 
 *  author: Daniel Rudigier
 *    date: 25.12.2008
 * 
 * 
 */
package at.syncme.aspects;

import at.syncme.framework.Game;
import at.syncme.framework.Event;

/**
 * some common point-cuts of the framework
 * 
 * @author Daniel Rudigier
 *
 */
public abstract aspect GameAspect {
    protected Game game;
    
    // after starting the game
    protected pointcut gameInit(): 
        call (at.syncme.framework.Game+.new());

    // before updating the game state
    protected pointcut gameUpdate(): 
        call (void at.syncme.framework.GameState+.updateGame());

    // when the game finished
    protected pointcut gameEnd(): 
        execution (void at.syncme.framework.Game+.end());

    // after starting the game
    protected pointcut gameStart(): 
        execution (void at.syncme.framework.Game+.start());
    
    // when a game was created
    protected pointcut eventCreated(): 
        call (at.syncme.framework.Event.new(..));
    
    // after an event was received
    protected pointcut eventReceived(): 
        call (Event at.syncme.framework.Event.materialize(..));
    
    // when a game was acknowledged
    protected pointcut eventAcknowledged(): 
        call (Event at.syncme.framework.Event.acknowledge());
    
    // when connections are available
    protected pointcut connectionsAvailable(): 
        execution (void at.syncme.framework.Game+.setConnectionUrls(..));
    
    // when connection state has changed
    protected pointcut connectState(): 
        execution (void at.syncme.framework.Game+.setConnected(..));
    
    /**
     * access the game.
     */
    after() returning (Game g): gameInit() {
        this.game = g;
    }

}
